#include "Tree.h"

BTNode* buyNode (char x)
{

	BTNode* node = (BTNode*) malloc (sizeof (BTNode)) ;
	node -> data = x ;
	node -> left = node -> right = NULL ;

	return node;
}

BTNode* createBinaryTree ()
{

    BTNode* nodeA = buyNode ('A') ;
	BTNode* nodeB = buyNode ('B') ;
	BTNode* nodeC = buyNode ('C') ;
	BTNode* nodeD = buyNode ('D') ;
	BTNode* nodeE = buyNode ('E') ;
	BTNode* nodeF = buyNode ('F') ;

	nodeA -> left = nodeB ;
	nodeA -> right = nodeC ;
	nodeB -> left = nodeD ;
	nodeC -> left = nodeE ;
	nodeC -> right = nodeF ;

	return nodeA;

}

void test ()
{

    BTNode* root = createBinaryTree () ;

    preOrder(root) ;

    printf ("\n") ;

	inOrder(root) ;

    printf ("\n") ;

	postOrder(root) ;

    printf ("\n") ;

	printf("size:%d\n", BinaryTreeSize (root)) ;

    printf("Leaf size:%d\n", BinaryTreeLeafSize(root)) ;

	printf("K size:%d\n", BinaryTreeLevelKSize(root, 1)) ;

	printf("depth:%d\n", BinaryTreeDepth(root)) ;

	if (BinaryTreeFind(root, 'G'))
	{

		printf("找到了\n") ;

	}

	else
	{

		printf("未找到\n") ;

	}

	printf ("使用层序遍历: ") ;

	leverOrder (root) ;

	BinaryTreeDestory(&root) ;

}

int main ()
{

    test () ;

    return 0 ;

}